package edu.mis.modules.orderDetail;

import java.util.List;
import edu.mis.model.OrderDetail;


import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;


public class OrderDetailService {
	public boolean addOrderDetail(OrderDetail orderDetail){
		return orderDetail.save();

	}
	public boolean updateOrderDetail(OrderDetail orderDetail){
		return orderDetail.update();
	}
	public boolean deleteOrderDetailById(int id) {
		return OrderDetail.dao.deleteById(id);
	}
	/**
	 * 根据ID得到该订单的信息
	 * @param id
	 * @return
	 */
	public OrderDetail findOrderDetailById(int id) {
		return OrderDetail.dao.findById(id);
	}

	public List<Record> findAllOrderDetailsWithCommodity(){
//		return Db.find("SELECT d.id,d.qty,c.commodityName,c.price FROM(SELECT * FROM order_detail  WHERE orderListId=2) d LEFT JOIN commodity c on d.commodityId=c.id");
		return OrderDetail.dao.findAllOrderDetailsWithCommodity("2");
	}
	public List<Record> findAllRecord(){
		return OrderDetail.dao.findAllRecord();
	}

	/**
	 * 查询所有订单明细
	 * @return
	 */
	public List<OrderDetail> findAll(){
		return OrderDetail.dao.findAll();
	}

}
